//
// Created by shen on 2025/2/27.
//

#ifndef VIDEOEDIT_SAFEQUEUE_H
#define VIDEOEDIT_SAFEQUEUE_H
extern "C"{
#include "libavcodec/avcodec.h"
}
#include "thread"
#include "queue"
#include "SWorkStatus.h"
#include <condition_variable>
#include <mutex>
class SafeQueue {
public:
    SafeQueue(FFStatus *ffStatus);

    virtual ~SafeQueue();



    void clearByBeforeTime(int64_t time,AVRational time_base);

    int putAvPacket(AVPacket *avPacket);
    int getAvPacket(AVPacket *avPacket);
    int getQueueSize();
    void clearAvPacket();
    void noticeQueue();
    double getMaxPts();

public:
    std::queue<AVPacket *> queuePacket;
    std::mutex mutex;
    std::condition_variable condPacket;

    FFStatus *ffStatus= nullptr;
};


#endif //VIDEOEDIT_SAFEQUEUE_H
